package component.security.hardware;

import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.InputStreamReader;
import java.util.Vector;

/**
 * Shell命令行工具
 */
public class Shell {
	public static Vector execute(String command) {
		Runtime sys = Runtime.getRuntime();		
		Vector result = new Vector();	
		DataInputStream in = null;
		BufferedReader reader = null;
		try {
			Process process= sys.exec(command);		
			in = new DataInputStream(process.getInputStream());
			reader = new BufferedReader(new InputStreamReader(in));
			String line;
			do {
				line = reader.readLine();
				if (line == null) {
					break;
				} else {
					result.addElement(line);
				}
			} while (true);			
			return result;
		} catch (Exception e) {	
			return null;
		} finally {			
			try {
				reader.close();			
			} catch(Exception ex) {				
			}
		}
	}
}
